/**
 * The OrCreationTool allows the user to create a new Or
 * by clicking at the place where there should be the top/left corner.
 * The rectangles currently have a fixed size of 100 by 100 pixels.
 * 
 * @author  Giuseppe Mendola (giuseppe.mendola@usi.ch);Gregory Banfi (gregory.banfi@usi.ch);
 */

package ch.usi.inf.pf2.gui;

import java.awt.event.MouseEvent;

import ch.usi.inf.pf2.Value;
import ch.usi.inf.pf2.Gates.Or;

public final class OrCreationTool extends Tool {

	public OrCreationTool(final Model model) {
		super(model, "Create Or Gate", "orGate.gif");
	}

	/**
	 * This method responds to the mouseClicked event on the orCreationTool.
	 * When the user clicks it prints a message, and creates a new or object at
	 * the position of the mouse clicked. Then the or is added to the drawing,
	 * the previous selection is cleared and the new or is selected.
	 */
	@Override
	public void mouseClicked(final MouseEvent ev) {
		System.out.println("mouseClicked: " + ev);
		final Or or = new Or(getInputPins(), getOutputPin(), ev.getX(),
				ev.getY());
		getDrawing().add(or);
		getSelection().clear();
		getSelection().add(or);
		getGates().add(or);
		Drawing.getInputs().clear();
	}

}
